package com.xm2.demo.system.customer.dao;

import com.xm2.demo.model.User;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import javax.persistence.Table;
import java.util.Collection;
import java.util.List;

/**
 * @Author
 * @Date 2018/12/14 11:20
 * @Description
 */
@Repository
@Table(name="user")
@Qualifier("CustomerRepository")
public interface CustomerRepository extends JpaRepository<User,Integer> {

    List<User> findByPositionId(Integer positionId);

    List<User> findByPositionId(Integer positionId, Pageable pageable);
    @Modifying
    @Query("update User u set u.phone = :phone where u.username = :username")
    Integer updateUserPhone(@Param("username") String username, @Param("phone") String phone);

    List<User> findByUsernameAndPositionId(String username, int positionId);

    User findById(Integer id);
}
